package bsw.wode.interceptor;

import java.util.Map;

import bsw.wode.config.SessionConstant;
import bsw.wode.entity.WodeUser;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LogonInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = 1806296708088389248L;

	
	@SuppressWarnings("unchecked")
	public String intercept(ActionInvocation ai) throws Exception {
		Map session = ai.getInvocationContext().getSession();
		WodeUser user = (WodeUser) session.get(SessionConstant.CUR_USER);
		if (null != user) {
			return ai.invoke();
		} else {
			return Action.LOGIN;
		}

	}

}
